/*
 * Copyright (c) 2017 Qunar.com. All Rights Reserved.
 */
package com.guoyu.project.model.enums;

import com.google.common.collect.Maps;

import java.util.List;
import java.util.Map;

/**
 * 文章一级类型
 * 
 * @author: libo Date: 17-5-25 Time: 上午11:01
 * @version: \$Id$
 */
public enum ArticleType {

    NEWS(1, "新闻动态", NewsType.values()),

    TRANSFORM(2, "转型方案", CollegeType.values()),

    RESULT(3, "项目成果", ResultType.values()),

    ANLI(4, "典型案例", AnliType.values()),

    POLICY(5, "政策文件", PolicyType.values()),

    PROJECT(6, "工程建设", ProjectType.values()),

    /**
     * 百校进展
     */
    PROGRESS(7, "百校进展", ProgessCategory.values()),

    ;

    private int code;
    private String desc;
    private ArticleMinorType[] minorTypes;

    ArticleType(int code, String desc, ArticleMinorType[] minorTypes) {
        this.code = code;
        this.desc = desc;
        this.minorTypes = minorTypes;
    }

    public String getDesc() {
        return desc;
    }

    public int getCode() {
        return code;
    }

    public ArticleMinorType[] getMinorTypes() {
        return minorTypes;
    }

    public String getName() {
        return this.name();
    }

    static Map<Integer, ArticleType> codeMapper = Maps.newHashMap();
    static {
        for (ArticleType majorType : values()) {
            codeMapper.put(majorType.getCode(), majorType);
        }
    }

    public static ArticleType codeOf(int code) {
        return codeMapper.get(code);
    }
}
